<!--  -->
<template>
  <div class="pending">
    <div class="tab_show">
      <el-tabs v-model="formInline.status" @tab-click="handleClick">
        <el-tab-pane label="全部" :name="null" />
        <el-tab-pane label="处理中" name="1" />
        <el-tab-pane label="已完成" name="2" />
        <el-tab-pane label="已取消" name="3" />
      </el-tabs>
      <!-- 搜索 -->
      <div class="formSearch">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="用户名">
            <el-input v-model="formInline.name" placeholder="请输入" />
          </el-form-item>
          <el-form-item label="反馈类型">
            <el-select v-model="formInline.type" placeholder="请选择反馈类型">
              <el-option label="全部" :value="null" />
              <el-option label="发货、物流、发票及安装问题" value="1" />
              <el-option label="退换货、维修、漏发问题" value="2" />
              <el-option label="商品使用与质量" value="3" />
              <el-option label="投诉与建议" value="4" />
              <el-option label="APP使用体验问题与建议" value="5" />
            </el-select>
          </el-form-item>
          <el-form-item label="时间">
            <el-date-picker
              v-model="formInline.dates"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" plain @click="search">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <!-- 表格 -->
      <div class="tableBox">
        <el-table
          ref="multipleTable"
          :data="tableData"
          border
          :header-cell-style="{ background: '#EEF3FF', color: '#333333' }"
          tooltip-effect="dark"
          style="width: 100%"
        >

          <el-table-column prop="name" label="用户" width="100" show-overflow-tooltip />
          <el-table-column prop="content" label="反馈内容"  show-overflow-tooltip />
          <el-table-column prop="tel" label="手机号" show-overflow-tooltip />
          <el-table-column prop="createTime" label="反馈时间" :formatter="formatData" show-overflow-tooltip />
          <el-table-column label="类型" show-overflow-tooltip>
            <template slot-scope="scope">
              <span v-if="scope.row.type == 1">发货、物流、发票及安装问题</span>
              <span v-if="scope.row.type == 2">退换货、维修、漏发问题</span>
              <span v-if="scope.row.type == 3">商品使用与质量</span>
              <span v-if="scope.row.type == 4">投诉与建议</span>
              <span v-if="scope.row.type == 5">APP使用体验问题与建议</span>
            </template>
          </el-table-column>
          <el-table-column label="处理状态" show-overflow-tooltip width="70">
            <template slot-scope="scope">
              <span v-if="scope.row.status == 1">处理中</span>
              <span v-if="scope.row.status == 2">已完成</span>
              <span v-if="scope.row.status == 3">已取消</span>
            </template>
          </el-table-column>

          <el-table-column label="操作" show-overflow-tooltip>
            <template slot-scope="scope">
              <div class="btnList">
                <el-button type="text" @click="del(scope.row)">查看</el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div class="fenye">
          <el-pagination
            :current-page="currentPage"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
//
import { getFeedbackList } from '@/api/feedback'
import { formatTime } from '@/api/formatDate'
export default {
  components: {},
  data() {
    // 这里存放数据
    return {
      activeName: 'first',
      formInline: {
        name: '', // 用户名
        status: '', // 订单状态
        dates: [], // 时间数组
        pageNum: 1,
        type: '',
        pageSize: 10
      },
      total: 1,
      tableData: [],
      currentPage: 1
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.getAll(this.formInline)
  },
  // 方法集合
  methods: {
    handleSizeChange(val) {
      this.formInline.pageSize = val
      this.getAll(this.formInline)
    },
    formatData(data) {
      const date = new Date(data.createAt)
      return formatTime(date, 'yyyy-MM-dd hh:mm')
    },
    handleCurrentChange(val) {
      this.formInline.pageNum = val
      this.getAll(this.formInline)
    },
    handleClick(tab, event) {
      console.log(tab)
      this.formInline.status = tab.name
      this.getAll(this.formInline)
    },
    //  查询
    search() {
      this.total = 1
      this.formInline.pageNum = 1
      this.getAll(this.formInline)
    },
    del(row) {
      this.$router.push({
        name: 'feedbackDetail',
        query: { id: row.id }
      })
    },
    // 初始化查询所有数据
    async getAll(formInline) {
      console.log(formInline, 'formInline')
      const res = await getFeedbackList(formInline)
      console.log(res, '初始化')
      this.total = res.data.total
      this.tableData = res.data.list
    }
  }
}
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
@import url("../../styles/elDialog.scss");
.tab_show {
  padding-left: 30px;
}
</style>
